grammar Statement;
import BaseLexer,BaseGrammar,Express;

program
    :
    statement
    ;

block
    :
    OpenBrace (statement SemiColon?)* CloseBrace
    ;
statement
    :
    express # exprStatement
    | Super  OpenParen  parameters?  CloseParen  # superStatement
    | SemiColon # emptyStatement
    | For OpenParen express SemiColon express SemiColon express CloseParen block # forStatement
    | express Dot ForEach OpenParen SimpleName Arrow block CloseParen # forEachStatement
    | While OpenParen express CloseParen block # whileStatement
    | Break # breakStatement
    | Switch OpenParen express CloseParen switchBlock # switchStatement
    | ifStatement # selectStatement
    | Continue # continueStatement
    | Return express? # returnStatement
    | Throw express # throwStatement
    | tryBlock catchBlock? finallyBlock? # tryCatchFinallyStatement
    ;

ifStatement
    :
    If OpenParen express CloseParen block  (Else (block|ifStatement))?
    ;

switchBlock
    :
    OpenBrace (switchCase (statement SemiColon?)*)* CloseBrace
    ;

switchCase
    :
    Case express Colon
    | Default Colon
    ;

tryBlock
    :
    Try block
    ;

catchBlock
    :
    Catch OpenParen parameterDeclaration CloseParen block
    ;

finallyBlock
    :
    Finally block
    ;